import {
  Controller,
  Get,
  Post,
  Query,
  Body,
  ParseIntPipe,
} from '@nestjs/common';
import { StudentDto } from './dtos/students.dto';
import { StudentsService } from './students.service';
import { User } from '../common/decorators';
@Controller('students')
export class StudentsController {
  constructor(private readonly studentsService: StudentsService) {}

  @Get('who-are-you')
  //   需要参数name
  whoAreYou(@Query('name') name: string) {
    return this.studentsService.ImStudent(name);
  }
  @Post('who-are-you-post')
  whoAreYouPost(@Body() student: StudentDto) {
    return this.studentsService.ImStudent(student.name);
  }
  @Get('get-name-by-id')
  getNameById(@Query('id', ParseIntPipe) id: number) {
    return this.studentsService.getStudentName(id);
  }

  @Post('who-is-request')
  whoIsReq(@User() user: string) {
    return user;
  }
}
